﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Jumpton.Persistent;
using Jumpton.SFA.Server.Entity;

namespace Jumpton.SFA.Server.BusinessRule.MasterData
{
    public class Product_UomsManager:BusinessLogic
    {
        public PRODUCT_UOMS Load(int ID)
        {
            return (PRODUCT_UOMS)ObjectRow.Load(typeof(PRODUCT_UOMS), string.Format("this.ID={0}", ID));
        }

        public PRODUCT_UOMS LoadID(string Code)
        {
            return (PRODUCT_UOMS)ObjectRow.Load(typeof(PRODUCT_UOMS), string.Format("this.UomsCode='{0}'", Code));
        }

        public PRODUCT_UOMS LoadNun(string denominator)
        {
            return (PRODUCT_UOMS)ObjectRow.Load(typeof(PRODUCT_UOMS), string.Format("this.DENOMINATOR='{0}'", denominator));
        }

        public ObjectTable GetProductUomsTable(decimal domainid,int productID)
        {
            return new ObjectTable(typeof(PRODUCT_UOMS), "this.DOMAINID='" + domainid + "' AND this.PRODUCTID='" + productID + "'");
        }

        public static PRODUCT_UOMS GetProductUom(decimal domainid, int productID)
        {
            return (PRODUCT_UOMS)ObjectRow.Load(typeof(PRODUCT_UOMS), string.Format("this.DOMAINID='{0}' AND this.PRODUCTID='{1}'", domainid, productID));
           // return new PRODUCT_UOMS(typeof(PRODUCT_UOMS), "this.DOMAINID='" + domainid + "' AND this.PRODUCTID='" + productID + "'");
        }

        public bool Save(PRODUCT_UOMS product_uoms)
        {
            try
            {
                //if(product_uoms.State == global::System.Data.DataRowState.Added)
                product_uoms.Save();
                

                return true;
            }
            catch (Exception ex)
            {
                
                this.message = ex.Message;
                throw ex;
            }
        }
    }
}
